﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.Net.Nntp
{
    using System;

    /// <summary>Represents a LIST NEWSGROUPS command to be sent to an NNTP server, see
    /// <a href="http://www.ietf.org/rfc/rfc3977.txt">RFC 3977</a> 7.6.6.</summary>
    /// <threadsafety static="true" instance="false"/>
    public sealed class ListNewsgroupsCommand : SingleLineCommand<ListNewsgroupsResponse>
    {
        private static readonly string[] SuccessResponseCodes = { "215" };

        /// <summary>Initializes a new instance of the <see cref="ListNewsgroupsCommand"/> class.</summary>
        public ListNewsgroupsCommand() : this(null, null)
        {
        }

        /// <summary>Initializes a new instance of the <see cref="ListNewsgroupsCommand"/> class.</summary>
        /// <exception cref="ArgumentNullException"><paramref name="wildmat"/> equals <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="wildmat"/> contains white space.</exception>
        public ListNewsgroupsCommand(string wildmat) : this(" ", wildmat)
        {
            CommandHelper.AssertContainsNoWhiteSpace("wildmat", wildmat);
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>See <see cref="SingleLineCommandBase{T, U}.CreateResponse"/>.</summary>
        protected sealed override ListNewsgroupsResponse CreateResponse(ResponseStream responseStream)
        {
            return new ListNewsgroupsResponse(responseStream);
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private ListNewsgroupsCommand(string separator, string arguments) :
            base("LIST NEWSGROUPS" + separator + arguments, 2, SuccessResponseCodes)
        {
        }
    }
}
